#        if n % x == 0:
#            print (n,  ' equals ',  x , '*',  n//x)
#            break
#    else:   #Loop statements may have an else; it is executed when 
#                #the loop terminates through exhaustion(with for) or when the condition 
#                # becomes false (with while), but not when the loop is terminated by a break
#        print(n, ' is prime')

#while True:
#    pass     # Busy-wait for keyboard interrupt (Ctrl+C)

def fibonnaci(n):   # define the function
    a, b =0, 1
    result = []
    while a<n:
        result.append(a)
        a, b = b, b+a
    return result
    
#fibonnaci(2000)     # call the function
#print (fibonnaci(0))
#f50 = fibonnaci(50)
#print(f50)

def ask_ok(prompt, retries=4,  complaint='Yes or no'):
    while True:
        ok = input(prompt)
                
        if ok in ('y',  'Y',  'Yes',  'yes'):
            return True
        if ok in ('n', 'N',  'No',  'no'):
            return False
        retries = retries - 1
        if retries == 0:
            raise IOError('bad answer')
        
        print (complaint)
        
#print(ask_ok("Give an answer:",complaint="y or n"))

def f(a, L=[]):
	L.append(a)
	return L

#print(f(1))
#print(f(2))
#print(f(3))

def cheeseshop(kind, *arguments, **keywords):
		"""Docstring Example.

		bla bla.
		"""
		print("-- Do you have any", kind, "?")
		print("-- I'm sorry, we're all out of", kind)
		for arg in arguments:
			print(arg)
		print("-" * 40)
		keys = sorted(keywords.keys())
		for kw in keys:
			print(kw, ":", keywords[kw])

#cheeseshop("Limburger", "It's very runny, sir.",
#           "It's really very, VERY runny, sir.",
#           shopkeeper="Michael Palin",
#           client="John Cleese",
#           sketch="Cheese Shop Sketch")

def concat(*args,sep="/"):
	return sep.join(args)

#print(concat("a","b","c"))
#print(cheeseshop.__doc__)

l = [1,2,3]
l.append(4)
l.extend([5,6])
l.insert(0,0)
l.remove(2)
#print(l)
#print(l.index(4))
l.reverse()
#print(l)
l.sort()
#print(l)
del l[2:5]
#print(l)

mat = [
		[1,2,3],
		[4,5,6],
		[7,8,9]
		]

#print([print(i) for i in mat])

#print ([str(round(355/113, i)) for i in range(1, 6)])

# set example:
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}  
#print ('orange' in basket)

# dictionary example:
tel = {'jack': 4098, 'sape': 4139}
tel['guido'] = 1992
#print (tel)
#print ('jack' not in tel)

#for a,b in tel.items():
	#print(a,": ",b)

a = [1,2,3,4]
b = [5,6,7,8]

#for i,j in zip(a,b):
#		print(' {0} with {1}'.format(i,j))

def file_operations(fisier):
	f= open(fisier,'r+')
	line = f.read(3)
	print (line,end="")

	line = f.readline()
	print (line,end='')

	for line in f:
		print (line,end='')

	f.write("this is a test\n")

	#seek is only for binary
#	f.seek(6,0)		# go to 6'th position after begining
#	print(f.readline())
#	f.seek(2,1)		# go 2 positions forward from current
#	print(f.readline())
#	f.seek(-3,2)	# go 3 positions before end
#	print(f.readline)
	f.close()

#file_operations("file.txt")

def function():
	while True:
		try:
			number=int(input("give a number "))
		except ValueError:
			print("I said number!")
		else:
			print("no exception was caught")
			break

	try:
		raise Exception("text1","text2")
	except Exception as inst:
			x,y = inst.args
			print("x=",x)
			print("Y=",y)

function()
